#ifndef GX_FR_ENGINE_SERIALIZATION_H
#define GX_FR_ENGINE_SERIALIZATION_H

#include "LibGL/GxMath3D.h"
#include "Basic/StringBuilder.h"
#include "Regex/MetaLexer.h"

namespace FinalRendering
{
	namespace Engine
	{
		using namespace GxLibBasic;

		typedef GxMetaParser::LexStream::LinkNode TokenNode;

		class Lex
		{
		public:
			enum TokenType
			{
				Int, Float, String, Comma, LBrace, RBrace,
				LBracket, RBracket,
				Identifier
			};
		};

		void PrintTab(StringBuilder & sb, int level);
		void NewLine(StringBuilder & sb, int level);
		void WriteInt(StringBuilder & sb, int level, const String & name, int value);
		void WriteFloat(StringBuilder & sb, int level, const String & name, float v);
		void WriteString(StringBuilder & sb, int level, const String & name, String & str);
		void WriteVector(StringBuilder & sb, vec3 & v);
		void BlockBegin(StringBuilder & sb, int & level);
		void BlockEnd(StringBuilder & sb, int & level);
		TokenNode * ReadToken(TokenNode *& token, Lex::TokenType type);
		TokenNode * ReadInt(TokenNode *& token, int * val);
		TokenNode * ReadFloat(TokenNode *& node, float * val);
		TokenNode * ReadString(TokenNode *& node, String * val);
		void ReadVector(TokenNode *& node, vec3 * v);
	}
}

#endif